{% extends 'front/front_base.html' %}

{% from 'common/_macro.html' import static %}

{% block title %}
{{ post.title }}
{% endblock %}
{% block head %}
    <script src="{{ static('ueditor/ueditor.config.js') }}"></script>
    <script src="{{ static('ueditor/ueditor.all.min.js') }}"></script>
    <script src="{{ static('front/js/front_pdetail.js') }}"></script>
    <link rel="stylesheet" href="{{ static('front/css/front_pdetail.css') }}">
{% endblock %}
{% block body %}
     <div class="lg-container">
         <div class="post-container">
             <div class="post-title">
                 <h2>{{ post.title }}</h2>
                 {% if post.highlight %}
                     <span class="label label-danger">置顶</span>
                     <img src="http://bbs.fishc.com/static/image/common/digest_3.gif" align="absmiddle" alt="digest"
                          title="精华 3">
                 {% endif %}
                 {% if post.firelag %}
                     <img src="http://bbs.fishc.com/static/image/common/hot_3.gif" align="absmiddle" alt="heatlevel"
                          title="热度: 1258">
                     <img src="http://bbs.fishc.com/static/image/common/agree.gif" align="absmiddle" alt="agree"
                          title="帖子被加分">
                 {% endif %}
             </div>
            <p class="post-info-group">
                <span>{{ post.author.username }}</span>
                <span>{{ post.create_time | handle_time }}</span>
                <span>{{ post.board.name }}</span>
                <span>阅读数：{{ post.read_count | int }}</span>
                <span>评论数：{{ post.comments | length }}</span>
            </p>
            <article id="post-content" data-id="{{ post.id }}"  class="post-txt">
                {{ post.content | safe }}
            </article>
        </div>
        <div class="comment-group">
            <h3>评论列表</h3>
            <ul class="comment-list-group">
                {% for comment in comments %}
                    <li>
                        <div class="comment-avatar">
                            <img src="{{ comment.author.avatar or static('imgs/front/logo.png') }}" alt="">
                        </div>
                        <div class="comment-content">
                            <p class="author-info">
                                <span>{{ comment.author.username }}</span>
                                <span>发表于{{ comment.create_time | handle_time }}</span>
                            </p>
                            <p class="comment-txt" data-post-id="{{ post.id }}" data-comment-id="{{ comment.id }}" data-content="{{ comment.content }}">
                                {{ comment.content | safe }}
                                {% if comment.origin_comment %}
                                    <div class="origin-comment-group">
                                    <blockquote>
                                        {{ comment.origin_comment.author.username }}发表于{{ comment.origin_comment.create_time }}
                                        <p>{{ comment.origin_comment.content|safe }}</p>
                                    </blockquote>
                                    </div>
                                {% endif %}
                                <a class=" btn-xs comment-reply-btn" data-toggle="modal" data-target="#myModal">回复</a>
                            </p>
                        </div>
                    </li>
                {% endfor %}
            </ul>
        </div>
        <div class="add-comment-group">
            <div class="comment-title">
                <h3>发表评论</h3>
            </div>
            <script  id="ueditor" type="text/plain"></script>
            <ul class="comment-btn">
                <button  class="btn btn-primary" id="add-comment">立即评论</button>
            </ul>
        </div>
     </div>
    <div class="sm-container">
        <div class="author-info-group">
            <div align="center" class="author-avatar">
                <img  src="{{ post.author.avatar or static('imgs/front/logo3.png') }}" alt="">
                <p class="author-name">
                    <span>{{ post.author.username }}</span>
                </p>
                <a href="{{ url_for('front.profile',user_id = post.author.id) }}" class="author-label">
                    <span class="label label-info">他的主页</span>
                </a>
            </div>

        </div>

    </div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">参与/主题回复</h4>
      </div>
      <div class="modal-body">
        <div class="modal-comment-info">
            {% for comment in post.comments %}
                        <p class="comment-info">
                <span>Re:{{ post.title }}</span>
            </p>
            <p class="comment-before-info">
                <span>
                    {{ comment.content | safe }}
                </span>
            </p>
            {% endfor %}
        </div>
          <div class="modal-comment-dialog">
                <script  id="ueditor1" type="text/plain"></script>
            </div>
      </div>
      <div class="modal-footer">
        <a type="button" class="btn btn-primary btn-xs">回复</a>
      </div>
    </div>
  </div>
</div>
{% endblock %}